<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

class Calendar
{

		public $startDay = 0;
		public $startMonth = 1;
		public $dayNames = array
		(
				0 => "星期日",
				1 => "星期一",
				2 => "星期二",
				3 => "星期三",
				4 => "星期四",
				5 => "星期五",
				6 => "星期六"
		);
		public $monthNames = array
		(
				0 => "1月",
				1 => "2月",
				2 => "3月",
				3 => "4月",
				4 => "5月",
				5 => "6月",
				6 => "7月",
				7 => "8月",
				8 => "9月",
				9 => "10月",
				10 => "11月",
				11 => "12月"
		);
		public $daysInMonth = array
		(
				0 => 31,
				1 => 28,
				2 => 31,
				3 => 30,
				4 => 31,
				5 => 30,
				6 => 31,
				7 => 31,
				8 => 30,
				9 => 31,
				10 => 30,
				11 => 31
		);

		public function Calendar( )
		{
		}

		public function getDayNames( )
		{
				return $this->dayNames;
		}

		public function setDayNames( $names )
		{
				$this->dayNames = $names;
		}

		public function getMonthNames( )
		{
				return $this->monthNames;
		}

		public function setMonthNames( $names )
		{
				$this->monthNames = $names;
		}

		public function getStartDay( )
		{
				return $this->startDay;
		}

		public function setStartDay( $day )
		{
				$this->startDay = $day;
		}

		public function getStartMonth( )
		{
				return $this->startMonth;
		}

		public function setStartMonth( $month )
		{
				$this->startMonth = $month;
		}

		public function getCalendarLink( $month, $year )
		{
				return "";
		}

		public function getDateLink( $day, $month, $year, $aid )
		{
				$dd = $year."-".$month."-".$day;
				$dd = strtotime( "".$dd."" );
				$acout = count( $aid ) - 1;
				$i = 1;
				for ( ;	$i <= $acout;	++$i	)
				{
						$bj = explode( "+", $aid[$i] );
						$ddd = strtotime( "".$bj[0]."" );
						if ( $ddd == $dd )
						{
								$link = $bj[1];
						}
				}
				return $link;
		}

		public function getCurrentMonthView( $aid, $lx )
		{
				$d = getdate( time( ) );
				if ( $lx == 1 )
				{
						$pl = array( );
						$xcc = explode( "~", $aid );
						$xccc = count( $xcc );
						$i = 1;
						for ( ;	$i < $xccc;	++$i	)
						{
								$xc = explode( "+", $xcc[$i] );
								$date = strtotime( "".$xc[1]."" ) - strtotime( "".$xc[0]."" );
								if ( $date < 0 )
								{
										return "";
								}
								$date /= 86400;
								$iq = 1;
								for ( ;	$iq <= $date;	++$iq	)
								{
										if ( $iq == 1 )
										{
												$co = strtotime( "".$xc[0]."" );
										}
										else
										{
												$co = $co;
										}
										$riqi = date( "Y-m-d", $co );
										array_push( &$pl, $riqi."+".$xc[2]."+".$xc[3]."+".$xc[4] );
										$co += 86400;
								}
						}
						$aid = $pl;
				}
				return $this->getMonthView( $d['mon'], $d['year'], $aid );
		}

		public function getCurrentMonthViewnext( $aid, $lx )
		{
				$d = getdate( time( ) );
				if ( $lx == 1 )
				{
						$pl = array( );
						$xcc = explode( "~", $aid );
						$xccc = count( $xcc );
						$i = 1;
						for ( ;	$i < $xccc;	++$i	)
						{
								$xc = explode( "+", $xcc[$i] );
								$date = strtotime( "".$xc[1]."" ) - strtotime( "".$xc[0]."" );
								if ( $date < 0 )
								{
										return "";
								}
								$date /= 86400;
								$iq = 1;
								for ( ;	$iq <= $date;	++$iq	)
								{
										if ( $iq == 1 )
										{
												$co = strtotime( "".$xc[0]."" );
										}
										else
										{
												$co = $co;
										}
										$riqi = date( "Y-m-d", $co );
										array_push( &$pl, $riqi."+".$xc[2]."+".$xc[3]."+".$xc[4] );
										$co += 86400;
								}
						}
						$aid = $pl;
				}
				return $this->getMonthView( $d['mon'] + 1, $d['year'], $aid );
		}

		public function getCurrentYearView( )
		{
				$d = getdate( time( ) );
				return $this->getYearView( $d['year'] );
		}

		public function getMonthView( $month, $year, $aid )
		{
				return $this->getMonthHTML( $month, $year, $showYear = 1, $aid );
		}

		public function getYearView( $year )
		{
				return $this->getYearHTML( $year );
		}

		public function getDaysInMonth( $month, $year )
		{
				if ( $month < 1 || 12 < $month )
				{
						return 0;
				}
				$d = $this->daysInMonth[$month - 1];
				if ( $month == 2 && $year % 4 == 0 )
				{
						if ( $year % 100 == 0 )
						{
								if ( $year % 400 == 0 )
								{
										$d = 29;
										return $d;
								}
						}
						else
						{
								$d = 29;
						}
				}
				return $d;
		}

		public function getMonthHTML( $m, $y, $showYear = 1, $aid )
		{
				$s = "";
				$a = $this->adjustDate( $m, $y );
				$month = $a[0];
				$year = $a[1];
				$daysInMonth = $this->getDaysInMonth( $month, $year );
				$date = getdate( mktime( 12, 0, 0, $month, 1, $year ) );
				$first = $date['wday'];
				$monthName = $this->monthNames[$month - 1];
				$prev = $this->adjustDate( $month - 1, $year );
				$next = $this->adjustDate( $month + 1, $year );
				if ( $showYear == 1 )
				{
						$prevMonth = $this->getCalendarLink( $prev[0], $prev[1] );
						$nextMonth = $this->getCalendarLink( $next[0], $next[1] );
				}
				else
				{
						$prevMonth = "";
						$nextMonth = "";
				}
				$yearr = $year."年";
				$header = ( 0 < $showYear ? " ".$yearr : "" ).$monthName;
				$s .= "<table cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#D8EAFE\"  class=\"dar\" >\r\n\n";
				$s .= "<tr>\n";
				$s .= "<td align=\"center\" valign=\"top\">".( $prevMonth == "" ? "&nbsp;" : "<a href=\"".$prevMonth."\">&lt;&lt;</a>" )."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\" colspan=\"5\">".$header."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\">".( $nextMonth == "" ? "&nbsp;" : "<a href=\"".$nextMonth."\">&gt;&gt;</a>" )."</td>\n";
				$s .= "</tr>\n";
				$s .= "<tr>\n";
				$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader lb\">".$this->dayNames[$this->startDay % 7]."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">".$this->dayNames[( $this->startDay + 1 ) % 7]."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">".$this->dayNames[( $this->startDay + 2 ) % 7]."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">".$this->dayNames[( $this->startDay + 3 ) % 7]."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">".$this->dayNames[( $this->startDay + 4 ) % 7]."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader\">".$this->dayNames[( $this->startDay + 5 ) % 7]."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\" class=\"calendarHeader lb\">".$this->dayNames[( $this->startDay + 6 ) % 7]."</td>\n";
				$s .= "</tr>\n";
				$d = $this->startDay + 1 - $first;
				while ( 1 < $d )
				{
						$d -= 7;
				}
				$today = getdate( time( ) );
				while ( $d <= $daysInMonth )
				{
						$s .= "<tr>\n";
						$i = 0;
						for ( ;	$i < 7;	++$i	)
						{
								$class = $year == $today['year'] && $month == $today['mon'] && $d == $today['mday'] ? "calendarToday" : "calendardate";
								$s .= "<td class=\"".$class."\" align=\"center\" valign=\"middle\">";
								if ( 0 < $d && $d <= $daysInMonth )
								{
										$link = $this->getDateLink( $d, $month, $year, $aid );
										if ( strtotime( "".$year."-".$month."-".$d."" ) < strtotime( "".$today['year']."-".$today['mon']."-".$today['mday']."" ) )
										{
												$s .= $link == "" ? $d : "{$d}<br><span style='color:#aaa;'>¥ {$link}</span>";
										}
										else
										{
												$s .= $link == "" ? $d : "<a href='#order'>".$d."<br><span>¥ {$link}</span></a>";
										}
										if ( $year == $today['year'] && $month == $today['mon'] && $d == $today['mday'] )
										{
												$s .= "(今天)";
										}
								}
								else
								{
										$s .= "&nbsp;";
								}
								$s .= "</td>\n";
								++$d;
						}
						$s .= "</tr>\n";
				}
				$s .= "</table>\n";
				return $s;
		}

		public function getYearHTML( $year )
		{
				$s = "";
				$prev = $this->getCalendarLink( 0, $year - 1 );
				$next = $this->getCalendarLink( 0, $year + 1 );
				$s .= "<table class=\"calendar\" border=\"0\">\n";
				$s .= "<tr>";
				$s .= "<td align=\"center\" valign=\"top\" align=\"left\">".( $prev == "" ? "&nbsp;" : "<a href=\"".$prev."\">&lt;&lt;</a>" )."</td>\n";
				$s .= "<td class=\"calendarHeader\" valign=\"top\" align=\"center\">".( 1 < $this->startMonth ? $year." - ".( $year + 1 ) : $year )."</td>\n";
				$s .= "<td align=\"center\" valign=\"top\" align=\"right\">".( $next == "" ? "&nbsp;" : "<a href=\"".$next."\">&gt;&gt;</a>" )."</td>\n";
				$s .= "</tr>\n";
				$s .= "<tr>";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 0 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 1 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 2 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "</tr>\n";
				$s .= "<tr>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 3 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 4 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 5 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "</tr>\n";
				$s .= "<tr>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 6 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 7 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 8 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "</tr>\n";
				$s .= "<tr>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 9 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 10 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "<td class=\"calendar\" valign=\"top\">".$this->getMonthHTML( 11 + $this->startMonth, $year, 0 )."</td>\n";
				$s .= "</tr>\n";
				$s .= "</table>\n";
				return $s;
		}

		public function adjustDate( $month, $year )
		{
				$a = array( );
				$a[0] = $month;
				$a[1] = $year;
				while ( 12 < $a[0] )
				{
						$a[0] -= 12;
						++$a[1];
				}
				while ( $a[0] <= 0 )
				{
						$a[0] += 12;
						--$a[1];
				}
				return $a;
		}

}

function litimgurls( $imgid = 0 )
{
		global $lit_imglist;
		$dsql = new DedeSql( FALSE );
		$row = $dsql->GetOne( "SELECT c.addtable FROM #@__archives AS a LEFT JOIN #@__channeltype AS c ON a.channel=c.id where a.id='".$imgid."'" );
		$addtable = trim( $row['addtable'] );
		$row = $dsql->GetOne( "Select imgurls From `".$addtable."` where aid='{$imgid}'" );
		$ChannelUnit = new ChannelUnit( 2, $imgid );
		$lit_imglist = $ChannelUnit->GetlitImgLinks( $row['imgurls'] );
		return $lit_imglist;
}

function okfromzj( $noo, $from, $to, $by, $zc, $zhc, $wc, $home, $xingcheng )
{
		$i = 0;
		for ( ;	$i < $noo;	++$i	)
		{
				$okfrom = array( );
				array_push( &$okfrom, "|".$from[$i] );
				array_push( &$okfrom, "|".$to[$i] );
				array_push( &$okfrom, "|".$by[$i] );
				array_push( &$okfrom, "|".$zc[$i] );
				array_push( &$okfrom, "|".$zhc[$i] );
				array_push( &$okfrom, "|".$wc[$i] );
				array_push( &$okfrom, "|".$home[$i] );
				array_push( &$okfrom, "|".$xingcheng[$i] );
				$okfromm .= "~".implode( $okfrom );
		}
		unset( $okfrom );
		return $okfromm;
}

function xcjd( $noo, $jd )
{
		$i = 0;
		for ( ;	$i < $noo;	++$i	)
		{
				$okfrom = array( );
				array_push( &$okfrom, $jd[$i] );
				$okfromm .= "~".implode( $okfrom );
		}
		unset( $okfrom );
		return $okfromm;
}

function getxcts( $aid, $ts, $table )
{
		$dsql = new DedeSql( FALSE );
		$xcts = $dsql->GetOne( "select ".$ts." from #@__{$table} where aid='{$aid}'" );
		$ts = explode( "~", $xcts["".$ts.""] );
		$ts = count( $ts );
		return $ts - 1;
}

function xxxc( $aid, $ts, $zd, $table, $ol )
{
		$dsql = new DedeSql( FALSE );
		$okfrom = array( );
		$xcts = $dsql->GetOne( "select ".$ol." from #@__{$table} where aid='{$aid}'" );
		$xcc = explode( "~", $xcts[$ol] );
		$i = 0;
		for ( ;	$i <= $ts;	++$i	)
		{
				$xc = explode( "|", $xcc[$i] );
				array_push( &$okfrom, $xc[$zd] );
		}
		return $okfrom;
}

function xxxcjd( $aid, $ts )
{
		$dsql = new DedeSql( FALSE );
		$okfrom = array( );
		$xcts = $dsql->GetOne( "select xcjd from #@__line where aid='".$aid."'" );
		$xcc = explode( "~", $xcts['xcjd'] );
		$i = 1;
		for ( ;	$i <= $ts;	++$i	)
		{
				array_push( &$okfrom, $xcc[$i] );
		}
		return $okfrom;
}

function xxxcbj( $aid, $ts, $zd )
{
		$dsql = new DedeSql( FALSE );
		$okfrom = array( );
		$xcts = $dsql->GetOne( "select bj from #@__line where aid='".$aid."'" );
		$xcc = explode( "~", $xcts['bj'] );
		$i = 0;
		for ( ;	$i <= $ts;	++$i	)
		{
				$xc = explode( "+", $xcc[$i] );
				array_push( &$okfrom, $xc[$zd] );
		}
		return $okfrom;
}

function xxxcplbj( $aid, $ts, $zd )
{
		$dsql = new DedeSql( FALSE );
		$okfrom = array( );
		$xcts = $dsql->GetOne( "select plbj from #@__line where aid='".$aid."'" );
		$xcc = explode( "~", $xcts['plbj'] );
		$i = 0;
		for ( ;	$i <= $ts;	++$i	)
		{
				$xc = explode( "+", $xcc[$i] );
				if ( !empty( $xc[0] ) )
				{
						array_push( &$okfrom, $xc[0] );
				}
				if ( !empty( $xc[1] ) )
				{
						array_push( &$okfrom, $xc[1] );
				}
		}
		return $okfrom;
}

function xxxcplbjjg( $aid, $ts, $zd )
{
		$dsql = new DedeSql( FALSE );
		$okfrom = array( );
		$xcts = $dsql->GetOne( "select plbj from #@__line where aid='".$aid."'" );
		$xcc = explode( "~", $xcts['plbj'] );
		$i = 0;
		for ( ;	$i <= $ts;	++$i	)
		{
				$xc = explode( "+", $xcc[$i] );
				if ( !is_null( $xc[2] ) )
				{
						array_push( &$okfrom, $xc[2] );
				}
				if ( !is_null( $xc[3] ) )
				{
						array_push( &$okfrom, $xc[3] );
				}
				if ( !is_null( $xc[4] ) )
				{
						array_push( &$okfrom, $xc[4] );
				}
		}
		return $okfrom;
}

function jdfxok( $noo, $fx, $zc, $chx, $kd, $mshj, $xfj, $fxpic, $fxxx )
{
		$i = 0;
		for ( ;	$i < $noo;	++$i	)
		{
				$okfrom = array( );
				array_push( &$okfrom, "|".$fx[$i] );
				array_push( &$okfrom, "|".$zc[$i] );
				array_push( &$okfrom, "|".$chx[$i] );
				array_push( &$okfrom, "|".$kd[$i] );
				array_push( &$okfrom, "|".$mshj[$i] );
				array_push( &$okfrom, "|".$xfj[$i] );
				array_push( &$okfrom, "|".$i );
				array_push( &$okfrom, "|".$fxpic[$i] );
				array_push( &$okfrom, "|".$fxxx[$i] );
				$okfromm .= "~".implode( $okfrom );
		}
		unset( $okfrom );
		return $okfromm;
}

function CheckMobile( $mobile )
{
		$mobile = isset( $mobile ) && is_numeric( $mobile ) ? $mobile : 0;
		if ( $mobile == "0" )
		{
				return "-1";
		}
		$dsql = new DedeSql( FALSE );
		$xcts = $dsql->GetOne( "select mid from #@__member where mb='".$mobile."'" );
		if ( $xcts )
		{
				return "-1";
		}
		return "0";
}

function Checkemaill( $email )
{
		$email = htmlspecialchars( $email );
		$email = str_replace( "　", " ", $email );
		$email = ereg_replace( "[\r\n\t ]{1,}", " ", $email );
		if ( $email == "" )
		{
				return "-1";
		}
		$dsql = new DedeSql( FALSE );
		$xcts = $dsql->GetOne( "select mid from #@__member where email='".$email."'" );
		if ( $xcts )
		{
				return "-1";
		}
		return "0";
}

function Checktjr( $tjr )
{
		$mobile = $tjr;
		$mobile = isset( $mobile ) && is_numeric( $mobile ) ? $mobile : 0;
		if ( $mobile == "0" )
		{
				return "-1";
		}
		$dsql = new DedeSql( FALSE );
		$xcts = $dsql->GetOne( "select mid from #@__member where mb='".$mobile."'" );
		if ( $xcts )
		{
				return "0";
		}
		return "-1";
}

function jiage( $aid )
{
		$dsql = new DedeSql( FALSE );
		$xcts = $dsql->GetOne( "select bj,plbj from #@__line where aid='".$aid."'" );
		$jiage = array( );
   if ($xcts['bj'] != "") {
        $xcc = explode("~", $xcts['bj']);
        $xccc = count($xcc);
        $i = 1;
        for (; $i < $xccc; ++$i) {
            do {

                $xc = explode("+", $xcc[$i]);
                array_push(&$jiage, $xc[1]);
                break;
            } while (1);
        }
    } else {
        $xcc = explode("~", $xcts['plbj']);
        $xccc = count($xcc);
        $i = 1;
        for (; $i < $xccc; ++$i) {
            $xc = explode("+", $xcc[$i]);
            if ($xc[2] != "") {
                array_push(&$jiage, $xc[2]);
            }
        }
    }
		sort( &$jiage );
		return $jiage[0];
}

function jiage_hotel( $aid )
{
		$dsql = new DedeSql( FALSE );
		$xcts = $dsql->GetOne( "select fx from #@__hotel where aid='".$aid."'" );
		$jiage = array( );
		$xcc = explode( "~", $xcts['fx'] );
		$xccc = count( $xcc );
		$i = 1;
		for ( ;	$i < $xccc;	++$i	)
		{
				$xc = explode( "~", $xcc[$i] );
				$xc = implode( $xc );
				$xcx = explode( "|", $xc );
				array_push( &$jiage, $xcx[6] );
		}
		sort( &$jiage );
		return $jiage[0];
}

function tianshu( $aid )
{
		$dsql = new DedeSql( FALSE );
		$xcts = $dsql->GetOne( "select xc from #@__line where aid='".$aid."'" );
		$xcc = explode( "~", $xcts['xc'] );
		return count( $xcc ) - 1;
}

function xlbj( $aid )
{
		$dsql = new DedeSql( FALSE );
		$xcts = $dsql->GetOne( "select bj,plbj from #@__line where aid='".$aid."'" );
		if ( $xcts['bj'] != "" )
		{
				$xcc = explode( "~", $xcts['bj'] );
				$xccc = count( $xcc );
				$i = 1;
				for ( ;	$i < $xccc;	++$i	)
				{
						$xc = explode( "+", $xcc[$i] );
						if ( $xc[2] == "" )
						{
								$xc[2] = 0;
						}
						$now = time( );
						$yesnoww = strtotime( "".$xc[0]."" );
						$dg = "√";
						if ( !( $yesnoww < $now ) )
						{
								$date .= "<option value=\"".$xc[0]."~".$xc[1]."~".$xc[2]."\">".$xc[0]."(".getweek( $xc[0] ).") ".$xc[1]."元/人 ".$xc[2]."元/儿童 (".$xc[3].")&nbsp;&nbsp;".$dg."</option>";
						}
				}
				return $date;
		}
		$xcc = explode( "~", $xcts['plbj'] );
		$xccc = count( $xcc );
		$i = 1;
		for ( ;	$i < $xccc;	++$i	)
		{
				$xc = explode( "+", $xcc[$i] );
				$date = strtotime( "".$xc[1]."" ) - strtotime( "".$xc[0]."" );
				if ( $date < 0 )
				{
						return "";
				}
				$date /= 86400;
				$iq = 1;
				for ( ;	$iq <= $date;	++$iq	)
				{
						if ( $iq == 1 )
						{
								$co = strtotime( "".$xc[0]."" );
						}
						else
						{
								$co = $co;
						}
						$riqi = date( "Y-m-d", $co );
						$now = time( );
						$yesnoww = strtotime( "".$riqi."" );
						$dg = "√";
						if ( !( $yesnoww < $now ) )
						{
								if ( $xc[3] == "" )
								{
										$xc[3] = 0;
								}
								$dater .= "<option value=\"".$riqi."~".$xc[2]."~".$xc[3]."\">".$riqi."(".getweek( $riqi ).") ".$xc[2]."元/人 ".$xc[3]."元/儿童 (".$xc[4].")&nbsp;&nbsp;".$dg."</option>";
						}
						$co += 86400;
				}
		}
		return $dater;
}

function pichdp( $aid )
{
		$dsql = new DedeSql( FALSE );
		$dsql->SetQuery( "select url from #@__uploads where arcid='".$aid."' and (mediatype='0' or mediatype='1')" );
		$u = 1;
		$dsql->Execute( );
		while ( $rowow = $dsql->GetObject( ) )
		{
				if ( !$rowow )
				{
						$pic = "picarr[1]=\"../../img/nopic.gif\";";
				}
				else
				{
						$pic .= "picarr[".$u."]=\"".$rowow->url."\";";
				}
				++$u;
		}
		return $pic;
}

function xllitpic( $aid )
{
		$dsql = new DedeSql( FALSE );
		$rowo = $dsql->getone( "select url from #@__uploads where arcid='".$aid."' and (mediatype='0' or mediatype='1')" );
		if ( !$rowo )
		{
				$pic = "../../img/nopic.gif";
				return $pic;
		}
		$pic = $rowo['url'];
		return $pic;
}

function getweek( $date )
{
		$date = date( "w", strtotime( $date ) );
		if ( $date == 1 )
		{
				$week = "周一";
				return $week;
		}
		if ( $date == 2 )
		{
				$week = "周二";
				return $week;
		}
		if ( $date == 3 )
		{
				$week = "周三";
				return $week;
		}
		if ( $date == 4 )
		{
				$week = "周四";
				return $week;
		}
		if ( $date == 5 )
		{
				$week = "周五";
				return $week;
		}
		if ( $date == 6 )
		{
				$week = "周六";
				return $week;
		}
		$week = "礼拜天";
		return $week;
}

function xlorder( $aid )
{
		$dsql = new DedeSql( FALSE );
		$row = $dsql->getone( "select ischeck from 188_order where aid='".$aid."'" );
		if ( $row['ischeck'] == 0 )
		{
				return "<font color=\"#FF0000\">未处理</font>";
		}
		return "<font color=\"#0000FF\">已处理</font>";
}

function title_pic( $aid )
{
		$dsql = new DedeSql( FALSE );
		$row = $dsql->getone( "select flag from 188_archives where id='".$aid."'" );
		if ( strstr( $row['flag'], "h" ) )
		{
				$pic .= "<img src=\"/img/i_hg.gif\"/>";
		}
		if ( strstr( $row['flag'], "c" ) )
		{
				$pic .= "<img src=\"/img/i_re.gif\"/>";
		}
		if ( strstr( $row['flag'], "a" ) )
		{
				$pic .= "<img src=\"/img/i_te.gif\"/>";
		}
		return $pic;
}

function jdxj( $aid )
{
		$dsql = new DedeSql( FALSE );
		$row = $dsql->getone( "select xj from 188_hotel where aid='".$aid."'" );
		if ( $row['xj'] == "一星" )
		{
				return "<img src=\"/img/x1.gif\" title=\"一星级酒店\"/>";
		}
		if ( $row['xj'] == "二星" )
		{
				return "<img src=\"/img/x2.gif\" title=\"二星级酒店\"/>";
		}
		if ( $row['xj'] == "三星" )
		{
				return "<img src=\"/img/x3.gif\" title=\"三星级酒店\"/>";
		}
		if ( $row['xj'] == "四星" )
		{
				return "<img src=\"/img/x4.gif\" title=\"四星级酒店\"/>";
		}
		if ( $row['xj'] == "五星" )
		{
				return "<img src=\"/img/x5.gif\" title=\"五星级酒店\"/>";
		}
}

function tsfw( $aid )
{
		$dsql = new DedeSql( FALSE );
		$row = $dsql->getone( "select ts from 188_hotel where aid='".$aid."'" );
		if ( strstr( $row['ts'], "宽带" ) )
		{
				$pic .= "<img src=\"/img/amenities_0.gif\" title=\"有宽度服务\"/>";
		}
		else
		{
				$pic .= "<img src=\"/img/amenities0.gif\" title=\"无宽度服务\"/>";
		}
		if ( strstr( $row['ts'], "早餐" ) )
		{
				$pic .= "<img src=\"/img/amenities_1.gif\" title=\"有早餐\"/>";
		}
		else
		{
				$pic .= "<img src=\"/img/amenities1.gif\" title=\"无早餐\"/>";
		}
		if ( strstr( $row['ts'], "接机服务" ) )
		{
				$pic .= "<img src=\"/img/amenities_2.gif\" title=\"有接机服务\"/>";
		}
		else
		{
				$pic .= "<img src=\"/img/amenities2.gif\" title=\"无接机服务\"/>";
		}
		if ( strstr( $row['ts'], "游泳池" ) )
		{
				$pic .= "<img src=\"/img/amenities_3.gif\" title=\"有游泳池\"/>";
		}
		else
		{
				$pic .= "<img src=\"/img/amenities3.gif\" title=\"无游泳池\"/>";
		}
		if ( strstr( $row['ts'], "停车场" ) )
		{
				$pic .= "<img src=\"/img/amenities_4.gif\" title=\"有停车场\"/>";
		}
		else
		{
				$pic .= "<img src=\"/img/amenities4.gif\" title=\"无停车场\"/>";
		}
		if ( strstr( $row['ts'], "健身房" ) )
		{
				$pic .= "<img src=\"/img/amenities_5.gif\" title=\"有健身房\"/>";
				return $pic;
		}
		$pic .= "<img src=\"/img/amenities5.gif\" title=\"无健身房\"/>";
		return $pic;
}

function keyd( )
{
		$dsql = new DedeSql( FALSE );
		$dsql->SetQuery( "select * from 188_keywords" );
		$dsql->Execute( );
		while ( $rowo = $dsql->GetObject( ) )
		{
				$ky .= $rowo->keyword.",";
		}
		return $ky;
}

function ReplaceKeyword( $kw, &$body )
{
		global $cfg_cmspath;
		global $dsql;
		$maxkey = 50;
		$kws = explode( ",", trim( $kw ) );
		$i = 0;
		$karr = $kaarr = $GLOBALS['GLOBALS']['replaced'] = array( );
		$body = preg_replace( "/(<a(.*))(>)(.*)(<)(\\/a>)/isU", "\\1-]-\\4-[-\\6", $body );
		foreach ( $kws as $k )
		{
				$k = trim( $k );
				$ca = "";
				$myrow = $dsql->GetOne( "select * from #@__keywords where keyword='".$k."' And rpurl<>'' " );
				if ( is_array( $myrow ) )
				{
						$ca = $myrow['rank'];
						$body = preg_replace( "/".$k."/", "<a href=".$myrow[rpurl].">".$k."</a>", $body, $ca );
				}
		}
		$body = preg_replace( "/(<a(.*))-\\]-(.*)-\\[-(\\/a>)/isU", "\\1>\\3<\\4", $body );
		return $body;
}

function xljdxc( $xc )
{
		$xc = explode( " ", $xc );
		$xcc = count( $xc );
		$dsql = new DedeSql( FALSE );
		$i = 0;
		for ( ;	$i < $xcc;	++$i	)
		{
				$row = $dsql->getone( "select arc.*,tp.*,arc.id as cid from `188_archives` arc left join `#@__arctype` tp on tp.id=arc.typeid where arc.title='".$xc[$i]."' and arc.channel='2' " );
				if ( $row )
				{
						$row['arcurl'] = getfileurl( $row['cid'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath'] );
						$pic .= "<a href=\"".$row['arcurl']."\" target=\"_blank\"><img src=\"".xllitpic( $row['cid'] )."\"><em>".$row['title']."</em></a>";
				}
		}
		return $pic;
}

function dingjin( $aid )
{
		$dsql = new DedeSql( FALSE );
		$myrow = $dsql->GetOne( "select dingjin from #@__line where aid='".$aid."' " );
		if ( $myrow )
		{
				return $myrow['dingjin'];
		}
		return "0";
}

function list_fx( $aid )
{
		$dsql = new DedeSql( FALSE );
		$myrow = $dsql->GetOne( "Select fx from `#@__hotel` where aid='".$aid."' {$limitsql}" );
		$xc1 = explode( "~", $myrow['fx'] );
		$xct = count( $xc1 );
		$i = 1;
		for ( ;	$i < $xct;	++$i	)
		{
				$xc2 = explode( "|", $xc1[$i] );
				$dt .= "<tr id=\"vl_t\" >\r\n        <td width=\"150\" valign=\"top\" colspan=\"2\"> &nbsp;&nbsp;<strong>".$xc2[1]."</strong>\r\n       </td>\r\n        <td valign=\"top\" >".$xc2[2]."</td>\r\n        <td valign=\"top\">".$xc2[3]."</td>\r\n        <td valign=\"top\">".$xc2[4]."</td>\r\n        <td valign=\"top\"><em>¥".$xc2[5]."</em></td>\r\n        <td  valign=\"top\"><em>¥".$xc2[6]."</em></td>\r\n         <td  valign=\"top\" align=\"center\"><input name=\"arc".$xc2[7]."\" type=\"checkbox\" id=\"arcID\" value=\"".$xc2[7]."\" class=\"np\" />\r\n</td>\r\n      </tr>";
		}
		return $dt;
}

function daxie( $number )
{
		if ( $number == "" )
		{
				return "";
		}
		$number = substr( $number, 0, 2 );
		$arr = array( "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" );
		if ( strlen( $number ) == 1 )
		{
				$result = $arr[$number];
				return $result;
		}
		if ( $number == 10 )
		{
				$result = "十";
				return $result;
		}
		if ( $number < 20 )
		{
				$result = "十";
		}
		else
		{
				$result = $arr[substr( $number, 0, 1 )]."十";
		}
		if ( substr( $number, 1, 1 ) != "0" )
		{
				$result .= $arr[substr( $number, 1, 1 )];
		}
		return $result;
}

function index_line($plbj, $pj) {
    if (!empty($plbj)) {
        $plbj = explode("~", $plbj);
        $co = count($plbj);
        $ii = 1;
        for (;$ii < $co;++$ii ) {
        do {
                $boj = explode("+", $plbj[$ii]);
                $sta = strtotime("" . $boj[0] . "");
                $sdo = strtotime("" . $boj[1] . "");
                if ($sdo < $sta) {
                    return "日期段错误";
                }
                $i = 1;
                for (;$i < 32;++$i) {
                    if (!( $sta <= $sdo )) {
                        continue;
                    }
                    $date .= date("n", $sta) . "月" . date("d", $sta) . "日 ";
                    $sta += 86400;
                }
                break;
            }while (1);
        } 
    } else {
        $pj = explode("~", $pj);
        $co = count($pj);
        $ii = 1;
        for (; $ii < $co; ++$ii) {
            $pjj = explode("+", $pj[$ii]);
            $pjj = explode("-", $pjj[0]);
            $date .= $pjj[1] . "月" . $pjj[2] . "日 ";
        }
    }
    return $date;
}

function gqxl( $bj, $plbj )
{
		$okfrom = array( );
		$okfromm = array( );
		if ( $plbj != "" )
		{
				$po = explode( "~", $plbj );
				$cot = count( $po );
				$i = 1;
				for ( ;	$i <= $cot;	++$i	)
				{
						$poo = explode( "+", $po[$i] );
						$cto = count( $poo );
						$ia = 0;
						for ( ;	$ia <= $cto;	++$ia	)
						{
								if ( strtotime( "".$poo[$ia]."" ) != "" )
								{
										array_push( &$okfrom, strtotime( "".$poo[$ia]."" ) );
								}
						}
				}
				if ( max( $okfrom ) - time( ) < "0" )
				{
						return "1";
				}
				return "2";
		}
		$ppo = explode( "~", $bj );
		$gg = count( $ppo );
		$ib = 0;
		for ( ;	$ib <= $gg;	++$ib	)
		{
				$pppo = explode( "+", $ppo[$i] );
				$coi = count( $pppo );
				$ic = 0;
				for ( ;	$ic <= $gg;	++$ic	)
				{
						if ( strtotime( "".$pppo[$ic]."" ) != "" )
						{
								array_push( &$okfromm, strtotime( "".$pppo[$ic]."" ) );
						}
				}
		}
		if ( max( $okfromm ) - time( ) < "0" )
		{
				return "1";
		}
		return "2";
}

function hqdyq( $mid )
{
		$dsql = new DedeSql( FALSE );
		$dyqs = array( );
		$sql = "select * from `#@__member_pms` where toid =".$mid." order by id desc limit 5";
		$dsql->SetQuery( $sql );
		$dsql->Execute( );
		while ( $rowd = $dsql->GetArray( ) )
		{
				$dyqs[] = $rowd;
		}
		return $dyqs;
}

function alipay_dyq( $mid )
{
		global $cfg_dyqgq;
		$dsql = new DedeSql( FALSE );
		$xtime = $cfg_dyqgq * 86400;
		$dyqs = array( );
		$sql = "select * from `#@__member_pms` where toid =".$mid." and hasview<>'0' and isadmin='0'  order by id desc limit 5";
		$dsql->SetQuery( $sql );
		$dsql->Execute( );
		while ( $rowd = $dsql->GetArray( ) )
		{
				if ( !( $rowd['sendtime'] <= $xtime ) )
				{
						$dyqs[] = $rowd;
				}
		}
		return $dyqs;
}

$abc188 = $_SERVER['SERVER_NAME'];
if ( $abc188 == "localhost" )
{
		$abc188 = "127.0.0.1";
}
$abc189 = explode( ".", $abc188 );
if ( $abc188 != "127.0.0.1" )
{
		$www = "cqe7";
		//if ( $abc189[0] != $www && $abc189[1] != $www )
		//{
				//echo "程序授权错误，请联系QQ：1002833370 (<a href=http://www.ew023.com >www.ew023.com</a>)";
				//exit( );
		//}
}

?>
